package net.hn.hnms.biz.common.activiti.builder;

import net.hn.hnms.biz.common.activiti.result.DeployResult;
import net.hn.hnms.biz.common.activiti.service.ProcessApiService;
import org.springframework.web.multipart.MultipartFile;


/**
 * Created on 2022/8/5.
 *
 * @author ly
 * @desc: 使用bpmn文件生产流程
 */
public class BpmnFileProcessCreator {


    //bpmn流程文件
    private MultipartFile bpmn;

    //流程图片
    private MultipartFile png;

    private ProcessApiService processApiService;

    private BpmnFileProcessCreator() {

    }

    public BpmnFileProcessCreator(ProcessApiService processApiService) {
        this.processApiService = processApiService;
    }

    public BpmnFileProcessCreator bpmn(MultipartFile bpmn) {
        this.bpmn = bpmn;
        return this;
    }

    public BpmnFileProcessCreator png(MultipartFile png) {
        this.png = png;
        return this;
    }

    /**
     * 部署流程
     * @return 生成流程并部署
     */
    public DeployResult deploy() {
        return processApiService.deployByBpmnFile(bpmn, png);
    }
}
